@echo off
REM --- AI 语音助手启动脚本 ---

REM Set CMD window to UTF-8
chcp 65001 >nul

echo --- 小牛助手正在运行... ---

REM Set Keys using the safest method
set "PICOVOICE_ACCESS_KEY=PICOVOICE_ACCESS_KEY"
set "BAIDU_API_KEY=BAIDU_API_KEY"
set "BAIDU_SECRET_KEY=BAIDU_SECRET_KEY"
set "BAIDU_LLM_API_KEY=BAIDU_LLM_API_KEY"

REM Define JAR Path
set JAR_FILE=target\ai-voice-assistant-1.0-SNAPSHOT.jar

REM Check for Java
where java >nul 2>nul
if %errorlevel% neq 0 (
    echo [ERROR] Java not found. Please check your PATH.
    pause
    exit /b 1
)

REM Check for JAR
if not exist %JAR_FILE% (
    echo [ERROR] JAR file not found: %JAR_FILE%
    echo Run "mvn clean package" first.
    pause
    exit /b 1
)

echo Keys loaded. JAR found. Starting application in new window...

start "AI Assistant Console" cmd /k java -Dfile.encoding=UTF-8 -jar %JAR_FILE%

echo Launch command sent. Closing this initial window in 3 seconds...
timeout /t 3 /nobreak >nul
exit /b 0